using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using CodePlex.DnD4eCampaignManager.CampaignManagerTests.TestUtilities;
using CodePlex.DnD4eCampaignManager.DnD4e.Interfaces;
using CodePlex.DnD4eCampaignManager.Presentation;
using CodePlex.DnD4eCampaignManager.Presentation.ViewInterfaces;
using CodePlex.DnD4eCampaignManager.Repositories.Interfaces;
using NUnit.Framework;
using Rhino.Mocks;
using StructureMap.AutoMocking;

namespace CodePlex.DnD4eCampaignManager.CampaignManagerTests.PresentationTests
{
    [TestFixture]
    public class CombatEncounterPresenterTests
    {
        private RhinoAutoMocker<CombatEncounterPresenter> _combatEncounterPresenterMocker;

        [Test]
        public void AddingAdditionInstancesOfTheSameCombatantSetsTheIndexTo2ForTheSecond3ForTheThirdEtc()
        {
            IMonster combatant = DefaultTestObjects.TestMonster();
            IMonster combatantA = DefaultTestObjects.TestMonster();
            IMonster combatantB = DefaultTestObjects.TestMonster();
            IMonster combatantC = DefaultTestObjects.TestMonster();

            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Stub(v => v.SelectedAvailableMonster).Return(combatant);
            _combatEncounterPresenterMocker.Get<IMonsterRepository>().Expect(mr => mr.GetByName(combatant.Name)).Return(combatantA);
            _combatEncounterPresenterMocker.Get<IMonsterRepository>().Expect(mr => mr.GetByName(combatant.Name)).Return(combatantB);
            _combatEncounterPresenterMocker.Get<IMonsterRepository>().Expect(mr => mr.GetByName(combatant.Name)).Return(combatantC);

            _combatEncounterPresenterMocker.ClassUnderTest.AddMonster();
            _combatEncounterPresenterMocker.ClassUnderTest.AddMonster();
            _combatEncounterPresenterMocker.ClassUnderTest.AddMonster();

            Assert.IsNull(combatantA.Index);
            Assert.AreEqual(2, combatantB.Index.GetValueOrDefault());
            Assert.AreEqual(3, combatantC.Index.GetValueOrDefault());
        }

        [Test]
        public void ChangesToThePreviouslySelectedMonsterArePulledFromTheViewAndStored()
        {
            IMonster previousCombatant = DefaultTestObjects.TestMonster();
            previousCombatant.Conditions = string.Empty;
            previousCombatant.HitPointsMaximum = 50;
            previousCombatant.HitPointsCurrent = 50;
            previousCombatant.HitPointsTemporary = 0;
            previousCombatant.InitiativeScore = 10;

            const string conditions = "Conditions!!";
            const int currentHitPoints = 20;
            const int temporaryHitPoints = 10;
            const int initiativeScore = 18;

            RhinoAutoMocker<CombatEncounterPresenter> combatEncounterPresenterMocker = new RhinoAutoMocker<CombatEncounterPresenter>();
            combatEncounterPresenterMocker.ClassUnderTest.PreviouslySelectedCombatant = previousCombatant;
            combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatantConditions).Return(conditions);
            combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatantCurrentHitPoints).Return(currentHitPoints);
            combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatantTemporaryHitPoints).Return(temporaryHitPoints);
            combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatantInitiativeScore).Return(initiativeScore);

            combatEncounterPresenterMocker.ClassUnderTest.PreviouslySelectedCombatant = previousCombatant;
            combatEncounterPresenterMocker.ClassUnderTest.SaveChangesToPreviouslySelectedCombatant();

            Assert.AreEqual(conditions, previousCombatant.Conditions);
            Assert.AreEqual(currentHitPoints, previousCombatant.HitPointsCurrent);
            Assert.AreEqual(temporaryHitPoints, previousCombatant.HitPointsTemporary);
            Assert.AreEqual(initiativeScore, previousCombatant.InitiativeScore);
        }

        [Test]
        public void ChangesToThePreviouslySelectedPlayerCharacterArePulledFromTheViewAndStored()
        {
            IPlayerCharacter previousCombatant = DefaultTestObjects.TestPlayerCharacter();
            previousCombatant.Conditions = string.Empty;
            previousCombatant.HitPointsMaximum = 50;
            previousCombatant.HitPointsCurrent = 50;
            previousCombatant.HitPointsTemporary = 0;
            previousCombatant.InitiativeScore = 10;
            previousCombatant.HealingSurgesMaximum = 10;
            previousCombatant.HealingSurgesCurrent = 10;

            const string conditions = "Conditions!!";
            const int currentHitPoints = 20;
            const int temporaryHitPoints = 10;
            const int initiativeScore = 18;
            const int currentHealingSurges = 6;

            _combatEncounterPresenterMocker.ClassUnderTest.PreviouslySelectedCombatant = previousCombatant;
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatantConditions).Return(conditions);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatantCurrentHitPoints).Return(currentHitPoints);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatantTemporaryHitPoints).Return(temporaryHitPoints);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatantInitiativeScore).Return(initiativeScore);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatantCurrentHealingSurges).Return(
                currentHealingSurges);

            _combatEncounterPresenterMocker.ClassUnderTest.PreviouslySelectedCombatant = previousCombatant;
            _combatEncounterPresenterMocker.ClassUnderTest.SaveChangesToPreviouslySelectedCombatant();

            Assert.AreEqual(conditions, previousCombatant.Conditions);
            Assert.AreEqual(currentHitPoints, previousCombatant.HitPointsCurrent);
            Assert.AreEqual(temporaryHitPoints, previousCombatant.HitPointsTemporary);
            Assert.AreEqual(initiativeScore, previousCombatant.InitiativeScore);
            Assert.AreEqual(currentHealingSurges, previousCombatant.HealingSurgesCurrent);
        }

        [Test]
        public void ChangesToThePreviouslySelectedPlayerCharacterAreSavedToTheRepository()
        {
            IPlayerCharacter previousCombatant = DefaultTestObjects.TestPlayerCharacter();

            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().Expect(r => r.Save(previousCombatant));

            _combatEncounterPresenterMocker.ClassUnderTest.PreviouslySelectedCombatant = previousCombatant;
            _combatEncounterPresenterMocker.ClassUnderTest.SaveChangesToPreviouslySelectedCombatant();
        }

        [Test]
        public void ClickingNextAdvancesTheCurrentCombatantToTheNextAccordingToInitiative()
        {
            IPlayerCharacter firstCombatant = DefaultTestObjects.TestPlayerCharacter();
            firstCombatant.Name = "Conan";
            firstCombatant.InitiativeScore = 19;
            IPlayerCharacter secondCombatant = DefaultTestObjects.TestPlayerCharacter();
            secondCombatant.Name = "Gandolf";
            secondCombatant.InitiativeScore = 17;
            IPlayerCharacter thirdCombatant = DefaultTestObjects.TestPlayerCharacter();
            thirdCombatant.Name = "Korgoth";
            thirdCombatant.InitiativeScore = 15;

            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().Stub(pcr => pcr.GetAllNames()).Return(
                new List<string> { firstCombatant.Name, secondCombatant.Name, thirdCombatant.Name }.AsReadOnly());
            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().Stub(pcr => pcr.GetByName(firstCombatant.Name)).Return(firstCombatant);
            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().Stub(pcr => pcr.GetByName(secondCombatant.Name)).Return(secondCombatant);
            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().Stub(pcr => pcr.GetByName(thirdCombatant.Name)).Return(thirdCombatant);

            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.CurrentCombatant = firstCombatant);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.CurrentCombatant = secondCombatant);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.CurrentCombatant = thirdCombatant);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.CurrentCombatant = firstCombatant);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.CurrentCombatant = secondCombatant);

            _combatEncounterPresenterMocker.ClassUnderTest.DisplayAvailablePlayerCharacters();
            _combatEncounterPresenterMocker.ClassUnderTest.AdvanceCombatToNextCombatant();
            _combatEncounterPresenterMocker.ClassUnderTest.AdvanceCombatToNextCombatant();
            _combatEncounterPresenterMocker.ClassUnderTest.AdvanceCombatToNextCombatant();
            _combatEncounterPresenterMocker.ClassUnderTest.AdvanceCombatToNextCombatant();
            _combatEncounterPresenterMocker.ClassUnderTest.AdvanceCombatToNextCombatant();
        }

        [Test]
        public void CombatantsCanBeRemovedFromTheCombat()
        {
            IPlayerCharacter combatantToRemove = DefaultTestObjects.TestPlayerCharacter();
            combatantToRemove.Name = "Gandolf";
            combatantToRemove.InitiativeScore = 17;
            IPlayerCharacter combatantToKeep = DefaultTestObjects.TestPlayerCharacter();
            combatantToKeep.Name = "Conan";
            combatantToKeep.InitiativeScore = 19;
            ICombatant[] combatants = new[] { combatantToKeep, combatantToRemove };
            ICombatant[] combatantsAfterRemovingOne = new[] { combatantToKeep };

            ReadOnlyCollection<string> playerCharacterNames = new List<string>
                                                                  {
                                                                      combatantToRemove.Name,
                                                                      combatantToKeep.Name
                                                                  }.AsReadOnly();
            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().Stub(pcr => pcr.GetAllNames()).Return(playerCharacterNames);
            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().Stub(pcr => pcr.GetByName(combatantToKeep.Name)).Return(combatantToKeep);
            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().Stub(pcr => pcr.GetByName(combatantToRemove.Name)).Return(
                combatantToRemove);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.Combatants = combatants);
            _combatEncounterPresenterMocker.ClassUnderTest.DisplayAvailablePlayerCharacters();

            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatant).Return(combatantToRemove);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.Combatants = combatantsAfterRemovingOne);

            _combatEncounterPresenterMocker.ClassUnderTest.RemoveSelectedCombatant();
//
//            using ( _mocks.Record() )
//            {
//                CombatEncounterView.Combatants = new ICombatant[] { };
//                CombatEncounterView.DeselectCombatant();
//                Expect.Call(CombatEncounterView.SelectedCombatant).Return(combatantToRemove);
//                Expect.Call(CombatEncounterView.SelectedCombatant).Return(combatantToRemove);
//                ICombatant combatant = new PlayerCharacter(new Defenses(), new Powers(), new Senses(), new Abilities(),
//                                                           new HealingSurges(new HitPoints()));
//                CombatEncounterView.SelectedCombatantDisplayEnabled = !string.IsNullOrEmpty(combatant.Name);
//                CombatEncounterView.SelectedCombatantName = combatant.DisplayName;
//                CombatEncounterView.SelectedCombatantInitiativeScore = combatant.InitiativeScore;
//                CombatEncounterView.SelectedCombatantConditions = combatant.Conditions;
//                CombatEncounterView.SelectedCombatantSpecialQualities = combatant.SpecialQualities;
//                CombatEncounterView.SelectedCombatantTactics = combatant.Tactics;
//                CombatEncounterView.SelectedCombatantCurrentHitPoints = combatant.HitPointsCurrent;
//                CombatEncounterView.SelectedCombatantTemporaryHitPoints = combatant.HitPointsTemporary;
//                IPlayerCharacter playerCharacter = combatant as IPlayerCharacter;
//                if ( playerCharacter != null )
//                {
//                    CombatEncounterView.SelectedCombatantAttackPowers = playerCharacter.PowersAtWill;
//                }
//                CombatEncounterView.Combatants = combatantsAfterRemovingOne.ToArray();
//            }
//            using ( _mocks.Playback() )
//            {
//                CombatEncounterPresenter = new CombatEncounterPresenter(CombatEncounterView, _playerCharacterRepository, _monsterRepository);
//                CombatEncounterPresenter.RemoveSelectedCombatant();
//            }
        }

        [Test]
        public void DisplayAvailableMonstersPushesAllMonstersToView()
        {
            IMonster monster1 = DefaultTestObjects.TestMonster();
            monster1.Name = "Conan";
            IMonster monster2 = DefaultTestObjects.TestMonster();
            monster2.Name = "Gandolf";
            List<string> monsterNames = new List<string> { monster2.Name, monster1.Name };
            ICombatant[] sortedMonsters = new ICombatant[] { monster1, monster2 };

            _combatEncounterPresenterMocker.Get<IMonsterRepository>().Stub(mr => mr.GetAllNames()).Return(monsterNames.AsReadOnly());
            _combatEncounterPresenterMocker.Get<IMonsterRepository>().Stub(mr => mr.GetByName(monster1.Name)).Return(monster1);
            _combatEncounterPresenterMocker.Get<IMonsterRepository>().Stub(mr => mr.GetByName(monster2.Name)).Return(monster2);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.AvailableMonsters = sortedMonsters);

            _combatEncounterPresenterMocker.ClassUnderTest.DisplayAvailableMonsters();
        }

        [Test]
        public void DisplayAvailableMonstersRetrievesAllMonstersFromRepository()
        {
            IMonster monster1 = DefaultTestObjects.TestMonster();
            monster1.Name = "Conan";
            IMonster monster2 = DefaultTestObjects.TestMonster();
            monster2.Name = "Gandolf";
            List<string> monsterNames = new List<string> { monster2.Name, monster1.Name };

            _combatEncounterPresenterMocker.Get<IMonsterRepository>().Expect(mr => mr.GetAllNames()).Return(monsterNames.AsReadOnly());
            _combatEncounterPresenterMocker.Get<IMonsterRepository>().Expect(mr => mr.GetByName(monster1.Name)).Return(monster1);
            _combatEncounterPresenterMocker.Get<IMonsterRepository>().Expect(mr => mr.GetByName(monster2.Name)).Return(monster2);

            _combatEncounterPresenterMocker.ClassUnderTest.DisplayAvailableMonsters();
        }

        [Test]
        public void DisplayAvailablePlayerCharactersRetrievesAllPlayerCharactersFromRepository()
        {
            ReadOnlyCollection<string> characterNames = new List<string> { "Gandolf", "Conan" }.AsReadOnly();
            IPlayerCharacter playerCharacter1 = DefaultTestObjects.TestPlayerCharacter();
            playerCharacter1.Name = "Gandolf";
            playerCharacter1.InitiativeScore = 17;
            IPlayerCharacter playerCharacter2 = DefaultTestObjects.TestPlayerCharacter();
            playerCharacter2.Name = "Conan";
            playerCharacter2.InitiativeScore = 19;

            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().Expect(pcr => pcr.GetAllNames()).Return(characterNames);
            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().Expect(pcr => pcr.GetByName(playerCharacter1.Name)).Return(
                playerCharacter1);
            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().Expect(pcr => pcr.GetByName(playerCharacter2.Name)).Return(
                playerCharacter2);

            _combatEncounterPresenterMocker.ClassUnderTest.DisplayAvailablePlayerCharacters();
        }

        [Test]
        public void DisplayAvailablePlayerCharactersRetrievesAllPlayerCharactersToView()
        {
            IPlayerCharacter playerCharacter1 = DefaultTestObjects.TestPlayerCharacter();
            playerCharacter1.Name = "Gandolf";
            playerCharacter1.InitiativeScore = 17;
            IPlayerCharacter playerCharacter2 = DefaultTestObjects.TestPlayerCharacter();
            playerCharacter2.Name = "Conan";
            playerCharacter2.InitiativeScore = 19;
            ReadOnlyCollection<string> characterNames = new List<string> { playerCharacter1.Name, playerCharacter2.Name }.AsReadOnly();
            ICombatant[] sortedCombatants = new ICombatant[] { playerCharacter2, playerCharacter1 };

            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().Stub(pcr => pcr.GetAllNames()).Return(characterNames);
            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().Stub(pcr => pcr.GetByName(playerCharacter1.Name)).Return(
                playerCharacter1);
            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().Stub(pcr => pcr.GetByName(playerCharacter2.Name)).Return(
                playerCharacter2);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.Combatants = sortedCombatants);

            _combatEncounterPresenterMocker.ClassUnderTest.DisplayAvailablePlayerCharacters();
        }

        [Test]
        public void GroupsOfMonstersCanBeAddedWithDifferentInitiativeScores()
        {
            GetMulitpleMonstersFromMockRepositoryAndPushThemToMockViewInOrder(DefaultTestObjects.TestMonster(), GetInitializedMonster(14),
                                                                              GetInitializedMonster(13, 2), GetInitializedMonster(12, 3),
                                                                              GetInitializedMonster(11, 4), GetInitializedMonster(10, 5));
            _combatEncounterPresenterMocker.ClassUnderTest.AddMultipleMonsters(5);
        }

        [Test]
        public void GroupsOfMonstersCanBeAddedWithDSameInitiativeScores()
        {
            const int initiativeScore = 10;
            GetMulitpleMonstersFromMockRepositoryAndPushThemToMockViewInOrder(DefaultTestObjects.TestMonster(),
                                                                              GetInitializedMonster(initiativeScore, 1),
                                                                              GetInitializedMonster(initiativeScore, 1),
                                                                              GetInitializedMonster(initiativeScore, 1),
                                                                              GetInitializedMonster(initiativeScore, 1),
                                                                              GetInitializedMonster(initiativeScore, 1));
            _combatEncounterPresenterMocker.ClassUnderTest.AddMultipleMonstersWithSameInitiative(5);
        }

        [Test]
        public void MonstersAddedToCombatHaveMaximumHitPoints()
        {
            IMonster monster = GetInitializedMonster(10, 5);
            monster.HitPointsCurrent = monster.HitPointsMaximum / 2;
            GetMulitpleMonstersFromMockRepositoryAndPushThemToMockViewInOrder(DefaultTestObjects.TestMonster(), monster);
            _combatEncounterPresenterMocker.ClassUnderTest.AddMonster();
            Assert.AreEqual(monster.HitPointsMaximum, monster.HitPointsCurrent);
        }

        [Test]
        public void MonstersAddedToCombatHaveNoConditions()
        {
            IMonster monster = GetInitializedMonster(10, 5);
            monster.Conditions = "Lots of nasty conditions";
            GetMulitpleMonstersFromMockRepositoryAndPushThemToMockViewInOrder(DefaultTestObjects.TestMonster(), monster);
            _combatEncounterPresenterMocker.ClassUnderTest.AddMonster();
            Assert.AreEqual(string.Empty, monster.Conditions);
        }

        [Test]
        public void MonstersAddedToCombatHaveZeroTemporaryHitPoints()
        {
            IMonster monster = GetInitializedMonster(10, 5);
            monster.HitPointsTemporary = 10;
            GetMulitpleMonstersFromMockRepositoryAndPushThemToMockViewInOrder(DefaultTestObjects.TestMonster(), monster);
            _combatEncounterPresenterMocker.ClassUnderTest.AddMonster();
            Assert.AreEqual(0, monster.HitPointsTemporary);
        }

        [Test]
        public void RefreshListOfCombatantsCausesTheCombatantsToBeResortedAndSentToTheView()
        {
            GetMulitpleMonstersFromMockRepositoryAndPushThemToMockViewInOrder(DefaultTestObjects.TestMonster(), GetInitializedMonster(10),
                                                                              GetInitializedMonster(11, 2), GetInitializedMonster(12, 3),
                                                                              GetInitializedMonster(13, 4), GetInitializedMonster(14, 5));
            _combatEncounterPresenterMocker.ClassUnderTest.AddMultipleMonsters(5);
        }

        [Test]
        public void SelectedCombatantIsDisplayedProperly()
        {
            IPlayerCharacter playerCharacter = DefaultTestObjects.TestPlayerCharacter();
            playerCharacter.Name = "Gandolf";
            playerCharacter.InitiativeScore = 17;
            playerCharacter.Conditions = "5 ongoing fire damage; save ends";

            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatant).Return(playerCharacter);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(
                v => v.SelectedCombatantDisplayEnabled = !string.IsNullOrEmpty(playerCharacter.Name));
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatantName = playerCharacter.DisplayName);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(
                v => v.SelectedCombatantInitiativeScore = playerCharacter.InitiativeScore);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatantConditions = playerCharacter.Conditions);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(
                v => v.SelectedCombatantSpecialQualities = playerCharacter.SpecialQualities);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatantTactics = playerCharacter.Tactics);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(
                v => v.SelectedCombatantCurrentHitPoints = playerCharacter.HitPointsCurrent);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(
                v => v.SelectedCombatantTemporaryHitPoints = playerCharacter.HitPointsTemporary);
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(v => v.SelectedCombatantAttackPowers = playerCharacter.PowersAtWill);

            _combatEncounterPresenterMocker.ClassUnderTest.UpdateViewWithNewlySelectedCombatant();
        }

        [SetUp]
        public void SetUp()
        {
            _combatEncounterPresenterMocker = new RhinoAutoMocker<CombatEncounterPresenter>();
        }

        [TearDown]
        public void TearDown()
        {
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().VerifyAllExpectations();
            _combatEncounterPresenterMocker.Get<IPlayerCharacterRepository>().VerifyAllExpectations();
            _combatEncounterPresenterMocker.Get<IMonsterRepository>().VerifyAllExpectations();
        }

        private void GetMulitpleMonstersFromMockRepositoryAndPushThemToMockViewInOrder(IMonster selectedMonster, params IMonster[] monsters)
        {
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Stub(v => v.SelectedAvailableMonster).Return(selectedMonster);
            foreach ( IMonster monster in monsters )
            {
                _combatEncounterPresenterMocker.Get<IMonsterRepository>().Expect(mr => mr.GetByName(selectedMonster.Name)).Return(monster);
            }
            _combatEncounterPresenterMocker.Get<ICombatEncounterView>().Expect(
                v => v.Combatants = monsters.OrderByDescending(x => x.InitiativeScore).ToArray());
        }

        private static IMonster GetInitializedMonster(int initiativeScore, int index)
        {
            IMonster initializedMonster = GetInitializedMonster(initiativeScore);
            initializedMonster.Index = index;
            return initializedMonster;
        }

        private static IMonster GetInitializedMonster(int initiativeScore)
        {
            IMonster initializedMonster = DefaultTestObjects.TestMonster();
            initializedMonster.InitiativeScore = initiativeScore;
            initializedMonster.Conditions = string.Empty;
            initializedMonster.HitPointsCurrent = initializedMonster.HitPointsMaximum;
            initializedMonster.HitPointsTemporary = 0;
            return initializedMonster;
        }
    }
}